#include "system.hpp"
#include "vga.hpp"
#include "idt.hpp"


namespace system{

    void fatal_error(const char * message){
        vga::printf("#C0FATAL ERROR:#0C %s",message);
        halt();
    }

    void beep_on(int freq){
        word scale = 1193046 / freq;
        outportb(0x43, 0xB6);
        outportb(0x42, (scale >> 0) & 0xff);
        outportb(0x42, (scale >> 8) & 0xff);
        outportb(0x61, inportb(0x61) | 3);
    }

    void beep_off(){
        outportb(0x61, inportb(0x61) &~ 3);
    }

    /*void beep(int freq, int duration){
        beep_on(freq);
        wait(duration);
        beep_off();
    }*/

}
